package net.shao.activity;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import net.shao.R;
import net.shao.adapter.TestAdapter;
import net.shao.base.BaseActivity;

import org.xutils.view.annotation.ViewInject;
import org.xutils.x;

import java.util.ArrayList;
import java.util.List;

public class RecyclerActivity extends BaseActivity {

    @ViewInject(R.id.recyclerview)
    private RecyclerView recyclerview;

    private TestAdapter adapter;
    private List<String> list;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_recycler);
        x.view().inject(this);

        list = new ArrayList<>();
        setData();

        adapter = new TestAdapter(this, list);
        recyclerview.setLayoutManager(new LinearLayoutManager(this));
        recyclerview.setAdapter(adapter);
    }

    private void setData() {
        for (int i = 0; i < 20; i++) {
            String str = "第" + i + "个条目";
            list.add(str);
        }
    }
}
